{{ template "header_" . }}

<h1>Project: <tt>{{ .Name }}</tt></h1>
<button onclick="deleteProject()">Delete</button>
<pre>{{ .JSON }}</pre>

<h2><a href="/internal/dashboard/connections?pid={{ .ID }}">Connections</a></h2>
{{ template "list_table_" .Connections}}

<h2><a href="/internal/dashboard/triggers?pid={{ .ID }}">Triggers</a></h2>
{{ template "list_table_" .Triggers}}

<h2><a href="/internal/dashboard/deployments?pid={{ .ID }}">Deployments</a></h2>
{{ template "list_table_" .Deployments}}

<h2><a href="/internal/dashboard/sessions?pid={{ .ID }}">Sessions</a></h2>
{{ template "list_table_" .Sessions}}

<h2><a href="/internal/dashboard/events?pid={{ .ID }}">Events</a></h2>
{{ template "list_table_" .Events }}

<h2>Resources</h2>
Hash: <pre>{{ .ResourcesHash }}</pre>
Content:
<pre>{{ .Resources }}</pre>

<script>
    function deleteProject() {
        if (confirm("Delete this project?")) {
            fetch("/internal/dashboard/projects/{{ .ID }}", {
                method: "DELETE",
            }).then(response => {
                if (response.ok) {
                    window.location.href = "/internal/dashboard/projects";
                } else {
                    console.error(response);
                    alert("Failed to delete project: " + response.statusText);
                }
            });
        }
    }
</script>

{{ template "footer_" . }}
